package com.app.news.util;

import android.content.ContentValues;
import android.content.Context;
import android.content.res.AssetManager;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class GetJsonNewsUtil {
    public  String getJson(Context context, String filename){
        //创建数据缓存器(空间)
        StringBuilder stringBuilder=new StringBuilder();
        //获取本地数据资源管理器
        AssetManager assetManager=context.getAssets();
        try {
            BufferedReader reader=new BufferedReader(new InputStreamReader(assetManager.open(filename)));
            String line;
            while ((line=reader.readLine())!=null){
                stringBuilder.append(line);
            }
        } catch (IOException e) {
            e.printStackTrace();
        }
        return stringBuilder.toString();
    }
}

